package com.bocom.hairy.crab.base.common.config;

import com.bocom.hairy.crab.base.common.SnowFlakeFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName com.bocom.hairy.crab.base.common.config.IDGenderConfig <br/>
 * @Description: 雪花算法配置类       <br/>
 * @Author jiangshikun             <br/>
 * @Date 2025/9/3 下午3:49         <br/>
 * @Version V1.0
 * ----------------------------------------
 * （^-^）心即理，知行合--致良知 （^-^）
 * 邮 箱:duzhuai@live.cn
 * 地 址：北京市海淀区永澄北路2号
 **/
@Configuration
@ConfigurationProperties(prefix = "snowflake")
public class IDGenderConfig {

    //数据中心[0,31] 配置文件中不配置就是0
    private long datacenterId;

    //机器标识[0,31] 配置文件中不配置就是0
    private long machineId;

    @Bean
    public SnowFlakeFactory getSnowFlakeFactory() {
        SnowFlakeFactory snowFlakeFactory = new SnowFlakeFactory(datacenterId,machineId);
        return snowFlakeFactory;
    }

    public long getDatacenterId() {
        return datacenterId;
    }

    public void setDatacenterId(long datacenterId) {
        this.datacenterId = datacenterId;
    }

    public long getMachineId() {
        return machineId;
    }

    public void setMachineId(long machineId) {
        this.machineId = machineId;
    }
}